<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            width: 100px;
            height: 100px;
            background-color: red;
            position: absolute;
        }
    </style>
</head>
<script>
    window.onload = function () {
        var box1 = document.getElementById("box1");
        //绑定鼠标移动事件
        document.onmousemove = function (event) {
            event = event ||window.event;
            var lift = event.clientX;
            var top = event.clientY;
            box1.style.left = lift + "px";
            box1.style.top = top + "px";
        };
    };
</script>
<body>
    <div id="box1"></div>
    sss
</body>
</html>